#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e5 + 10;
vector<int>c(N);
int a, b, d, m, n, sum;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> a >> b;
	for (int i = 1; i <= a; i++) {
		cin >> d;
		c[i] = c[i - 1] + d;
	}
	while (b--) {
		cin >> m >> n;
		sum = c[n] - c[m - 1];
		printf("%lld\n", sum);
	}
}
